def last_sum(n):
    if n <= 0:
        return 0
    else:
        first= 1
        q= 1/2
        sum= first*(1-q**n)/(1-q)
        return sum
n = 5
sum=last_sum(n)
print("该式子到n的计算结果是:",sum)